package shopping;

public class Product {
    //定义商品的基本属性：名称（name）、种类（type）、价格（price）和库存数量（stock）。
    private String name;
    private String type;
    private double price;
    private int stock;


    public Product() {
    }

    public Product(String name, String type, double price, int stock) {
        this.name = name;
        this.type = type;
        this.price = price;
        this.stock = stock;
    }
    //提供属性的getter和setter方法
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public int getStock() {
        return stock;
    }

    public void setStock(int stock) {
        this.stock = stock;
    }

    //一个toString方法用于展示商品信息
public String toString(){
        return "商品："+getName()+" 种类："+getType()+" 单价："+getPrice()+
                " 库存："+getStock();
}

}
